<template>
	<view class="join-help">
		<view class="bg">
			<!-- <image src="../../static/image/bg1.png" mode=""></image> -->
			<image src="../../static/image/index_1.png" mode=""></image>
		</view>
		<view class="join-box">
			<!-- <image src="../../static/image/bg2.png" mode="" class="small-people"></image> -->
			<!-- <image :src="info.image" mode="" class="adv"></image> -->
			<!-- <image src="../../static/image/pic1.png" mode="" class="adv"></image> -->
			<view class="select-persone flex flai">
				<view class="select-list" @click="selectClick(index)" v-for="(item,index) in homeList" :key="item.id">
					<image :src="item.imgs" mode=""></image>
					<text>{{item.relationName}}</text>
					<view class="" v-if="item.isClick">
						<image src="../../static/image/select.jpg" mode="" class="slect-right" v-show="item.isSelect"></image>
						<image src="../../static/image/noSelect.png" mode="" class="slect-right" v-show="!item.isSelect"></image>
					</view>

				</view>
			</view>
			<view class="join-btn" :class="[isBtn?'gray-btn':'']" @click="bindMobile">
				每人{{money}}元，立即加入
			</view>
			<view class="rule flex flai">
				<view class="checkbox" @click="agree">
					<image src="../../static/image/checkBoxSelect.png" mode="" v-if="isChecked"></image>
					<image src="../../static/image/checkBox.png" mode="" v-else></image>
				</view>
				<text>我已阅读并同意</text>
				<navigator :url="'/pages/protocol/health?planId='+ planId+'&index=0'+'&type=1'">《蜜袋互助会员协议》</navigator>
			</view>
		</view>
		<view class="intr-box">
			<view class="intr-title">
				2020年每加入一名成员，平台将 <text>捐赠40～80元</text>不等到互助基金账户，支持互助计划！
			</view>
			<view class="intr-left flex flai">
				<image src="../../static/image/index_2.png" mode="" style="margin-left:20rpx;"></image>
				<view class="desc-right" style="margin-right: 20rpx;">

					<view class="desc-con">
						如果您是IT、快递员、外卖小哥、工地或工厂工人、高空作业等职业人群，您成功加入后，平台将为您额外购买意外保险！
                            
					</view>
				</view>
			</view>
			<view class="intr-left flex flai" style="background:rgba(255,244,244,1);">
				<image src="../../static/image/index_4.png" mode="" style="margin-left:20rpx;width:161rpx;height: 240rpx;"></image>
				<view class="desc-right">
					<view class="desc-con">
						如果您是本次“战疫”逆行的医护人员，或是英雄直系家属，您可申请免费加入，平台将为1000名英雄买单！
					</view>
				</view>

			</view>

			<view class="know-title">
				了解蜜袋互助
			</view>
			<view class="bg-shdow">

				<view class="know-box">
					<image src="../../static/image/index_6.png" mode="" style="width:590rpx;height:373rpx"></image>
					<view class="konw-intr">
						蜜袋互助是专为中低收入人群打造的大病互助共济服务。基于“一人患病、众人分摊”的原则，依托绿色能源稳定发电收益，为不幸罹患重大疾病的成员提供最长20年最高35万元的互助金。
					</view>
					<view class="konw-intr" style="margin-top:10rpx">
						每一个加入的会员只要购买一个光伏组件就可以选择加入到蜜袋互助计划中来！不仅帮助绿色能源产业健康发展（属于5G“新基建”范畴），也能够让产业健康发展所产生的电费收益来支持会员的大病互助计划！
					</view>
				</view>
				<view class="join-good-box">
					<view class="join-good-title">
						加入享最长<text>20年</text>最高<text>35万</text>的互助金
					</view>
					<view class="join-good-intr">
						<image src="../../static/image/index_7.png" mode="" style="width:600rpx;height:445rpx ;"></image>
						<view class="join-rule">
							<view class="flex">
								<text>加入年龄</text>
								<text>0~60周岁（含60周岁当年）</text>
							</view>
							<view class="flex">
								<text>保障范围</text>
								<text>101种重疾（含癌症）</text>
							</view>
						</view>
						<view class="join-rule-list">
							<view class="flex flai">
								<image src="../../static/image/index_14.png" mode=""></image>
								<text>门槛低</text>
								<text>30天~60周岁可加入</text>
							</view>
							<view class="flex flai">
								<image src="../../static/image/index_14.png" mode=""></image>
								<text>可叠加</text>
								<text>与医保商保不冲突</text>
							</view>
							<view class="flex flai">
								<image src="../../static/image/index_14.png" mode=""></image>
								<text>更便捷</text>
								<text>无需报销，确诊申领</text>
							</view>
							<view class="flex flai">
								<image src="../../static/image/index_14.png" mode=""></image>
								<text>更省事</text>
								<text>一次付费，后续无需再充值</text>
							</view>
							<view class="flex flai">
								<image src="../../static/image/index_14.png" mode=""></image>
								<text>更灵活</text>
								<text>互助权益可转赠家人</text>
							</view>

						</view>
					</view>
				</view>

			</view>
			<view class="different-box">
				<view class="different-title">
					我们有何不同
				</view>
				<image src="../../static/image/index_15.png" mode="" style="width: 670rpx;height: 1070rpx;"></image>
				<!-- <view class="different flex flai">
					.<view class="different-left">
						<view class="contrast-title">
							其他互助
						</view>
						<view class="different-list">
							<view class="small-title">
								每期支付分摊金额，无分摊上限，成本不定
							</view>
							<view class="small-con">
								当前市面上的互助计划基本是根据年龄来计算进行分摊，后期分摊金额上涨的机率非常大，大部分平台要求绑定支付端或银行卡，以实现自动扣缴，所花成本无法确定。且如果中间断缴，则基本被默认为自动退出，无法享受后期互助保障不说，前面所分摊的钱也付诸东流。
							</view>
						</view>
						<view class="different-list">
							<view class="small-title">
								自主退出无补偿
							</view>
							<view class="small-con">
								如因个人原因造成退出的，不仅无法追回之前付出的分摊金额，也无法再有资格享受后期互助保障。
							</view>
						</view>
						<view class="different-list">
							<view class="small-title">
								单一互助公益属性
							</view>
							<view class="small-con">
								仅是大病互助的单一互助公益属性。
							</view>
						</view>
					</view>
					<view class="different-right">
						<view class="contrast-title">
							蜜袋互助
						</view>
						<view class="different-list">
							<view class="small-title">
								持光伏组件入场，后续无需再充值

							</view>
							<view class="small-con">
								光伏组件作为光伏电站的一部分，电站产生的最长20年的发电收益，因此，会员只需一次性购买光伏组件，持有光伏组件加入互助计划，其光伏电站的发电收益可用于支持互助计划，无需会员再做后续充值分摊。

							</view>
						</view>
						<view class="different-list">
							<view class="small-title">
								自主退出后仍然可享受光伏组件带来的收益
							</view>
							<view class="small-con">
								自退出后的第二个月之后，可享受自有光伏组件的份额收益。

							</view>
						</view>
						<view class="different-list">
							<view class="small-title">
								互助+绿色环保双公益

							</view>
							<view class="small-con">
								守护家人，帮助他人的同时，助力新能源光伏产业的健康发展，让我们生活和环境更加绿色美好！

							</view>
						</view>
					</view>
				</view> -->
			</view>
			<view class="box">


				<view class="why-jion">
					<view class="why-title">为什么加入互助？</view>

					<view class="why-list-box">
						<view class="why-list flex">
							<image src="../../static/image/why1.png" mode=""></image>
							<view class="why-list-right flex fljcsb flex1">
								<text>防范未然</text>
								<text>人生不如意事 十有八九</text>
								<text>得癌症概率36%；得大病的概率72%</text>
							</view>

						</view>
						<view class="why-list flex">
							<image src="../../static/image/why2.png" mode=""></image>
							<view class="why-list-right flex fljcsb flex1">
								<text>保障自己</text>
								<text>一夜回到解放前</text>
								<text>大病治疗费10万～50万=普通家庭3-5年积蓄</text>
							</view>

						</view>
						<view class="why-list flex">
							<image src="../../static/image/why3.png" mode=""></image>
							<view class="why-list-right flex fljcsb flex1">
								<text>爱心公益</text>
								<text>我为人人，感恩社会帮助他人</text>
								<text></text>
							</view>

						</view>
					</view>
				</view>
			</view>
			<view class="slide-index">
				<view class="safe-title">
					平台运营安全可靠
				</view>
				<swiper duration="300" next-margin="240rpx">
					<swiper-item>
						<view class="swiper-item">
							<image src="../../static/image/index8.png" mode=""></image>
							<view class="slide-title">
								中国建设银行存管互助金，让资金安全透明且专款专用！
							</view>
							<view class="safe-con">
								互助金账户为中国建设银行的“监管易”账户，互助金在中国建设银行存管，严格按照协议要求执行和监督，安全透明，专款专用。
							</view>
						</view>
					</swiper-item>
					<swiper-item>
						<view class="swiper-item">
							<image src="../../static/image/index9.png" mode=""></image>
							<view class="slide-title">
								中国人民保险承保光伏资产，让光伏资产安全有保障！
							</view>
							<view class="safe-con">
								所有光伏电站均在中国人民保险公司承保，进一步保障电站资产安全。
							</view>
						</view>
					</swiper-item>
					<swiper-item>
						<view class="swiper-item">
							<image src="../../static/image/index10.png" mode=""></image>
							<view class="slide-title">
								蚂蚁区块链司法存证，让发电协议数据数据真实可靠！
							</view>
							<view class="safe-con">
								每一份签署的协议及每座光伏电站的发电数据、运营数据、互助金发放情况都将记录到蚂蚁区块链上（联动互联网法院），实现数据公开透明，真实可靠，且是可追溯和不可篡改的。
							</view>
						</view>
					</swiper-item>
					<swiper-item>
						<view class="swiper-item">
							<image src="../../static/image/index11.png" mode=""></image>
							<view class="slide-title">
								e签宝签章电子化且被司法鉴定机构直接采纳，让司法维权更轻松！
							</view>
							<view class="safe-con">
								每一份协议都采用的e签宝电子签章技术，其技术已联动了国家信息中心电子数据司法鉴定中心、公证处、仲裁委、互联网法院等司法认证/鉴定机构，轻松解决维权问题。
							</view>
						</view>
					</swiper-item>
				</swiper>
			</view>
		</view>


		<!-- 	<view class="box">
			<view class="why-jion-help">
				<view class="why-title" style="margin-left: 40rpx;text-align: left;">为什么加入蜜袋互助？</view>
				<image src="../../static/image/why4.png" mode="" class="why4"></image>
				<image src="../../static/image/why5.png" mode="" class="why5"></image>
			</view>
		</view> -->

		<view class="box" style="padding-bottom: 30rpx;margin-top:40rpx;">


			<view class="why-title" style="margin-left: 40rpx;text-align: left;margin-top:20rpx">合作伙伴</view>
			<view class="friend flex fljcsb">
				<image src="../../static/image/hzc3.png" mode=""></image>
				<image src="../../static/image/hzc4.png" mode=""></image>
				<image src="../../static/image/hzc5.png" mode=""></image>
				<image src="../../static/image/hzc6.png" mode=""></image>
				<image src="../../static/image/hzc7.png" mode=""></image>
				<image src="../../static/image/hzc8.png" mode=""></image>
				<image src="../../static/image/hzc9.png" mode=""></image>
				<image src="../../static/image/hzc1.png" mode=""></image>
				<image src="../../static/image/hzc2.png" mode=""></image>
			</view>
		</view>
		<view class="box" style="margin-top:40rpx;padding-bottom: 40rpx;">
			<view class="why-title" style="margin-left: 40rpx;text-align: left;margin-bottom: 20rpx;">常见问题</view>
			<view class="question-box">
				<view class="question-list" v-for="(item,index) in questionList" :key="item.id">
					<view class="question-title flex fljcsb" @click="showOrHide(index)">
						<view class=" flex">
							<image src="../../static/image/quest.png" mode="" style="width: 30rpx;height: 30rpx;margin-right:10rpx;margin-top:10rpx"></image>
							<text>{{index+1}}、</text><text class="flex1">{{item.title}}</text>
						</view>

						<image src="../../static/image/arrow-right.png" mode="" class="arrow-right" :class="[item.isSelect?'translate':'']"></image>
					</view>
					<view class="question-con" :style="{'display':item.isSelect?'block':'none'}">
						{{item.question}}
					</view>
				</view>
			</view>
		</view>

		<view style="height: 320rpx;" v-if="isFix">

		</view>

		<view style="padding-bottom: 50rpx;" :class="[isFix?'btn-fix':'']">
			<view class="join-btn" :class="[isBtn?'gray-btn':'']" style="margin:40rpx auto 140rpx auto" @click="bindMobile(1)">
				每人{{money}}元，立即加入
			</view>
		</view>
		<view class="mask" v-if="isShow"></view>
		<view class="popup" :style="{'bottom':bottom}">
			<view class="popup-head flex flai fljcsb">
				<image src="../../static/image/close.png" mode="" class="close" @click="close(2)"></image>
				<text v-if="type==1">请选择父母</text>
				<text v-if="type==2">请选择子女数量</text>
				<view class="finshed-btn" @click="close(2)">完成</view>
			</view>
			<view class="propt" v-if="type==1">
				父母年龄需要在<text style="color: #66BE00;"> 60周岁 </text>以下哟
			</view>
			<view class="popup-box" v-if="type==1">
				<view class="popup-list flex" v-for="(item,index) in prentList" :key="item.id" @click="selectParent(index)">
					<text class="flex1" :style="{'color':item.isSelect?'#66BE00':''}">{{item.name}}</text>
					<view class="select-kinsfolk">
						<image src="../../static/image/right.png" v-if="item.isSelect"></image>
					</view>
				</view>
			</view>
			<view class="popup-box" v-if="type==2">
				<view class="popup-list flex" v-for="(item,index) in sonList" :key="item.id" @click="selectSonClick(index)">
					<text class="flex1" :style="{'color':item.isSelect?'#66BE00':''}">{{item.name}}</text>
					<view class="select-kinsfolk">
						<image src="../../static/image/right.png" v-if="item.isSelect"></image>
					</view>
				</view>
			</view>
		</view>
		<!-- 手机号验证弹框 -->
		<view class="mask1" v-if="mobileShow">
			<view class="mobile-alert">
				<view class="mobile-head flex flai">
					<view class="mobile-title flex1">绑定手机号</view>
					<image src="../../static/image/close.png" mode="" class="close" @click="closeMobileAlert"></image>
				</view>
				<view class="moble-form">
					<view class="section flex flai">
						<input type="number" @blur.prevent="changeBlur()" value="" maxlength="11" v-model="mobile" class="flex1"
						 placeholder="请输入手机号" />
						<button :disabled="phoneBtn" @click="getMobileCode">{{phoneMsg}}</button>
					</view>
					<view class="section flex flai">
						<input type="number" @blur.prevent="changeBlur()" maxlength="6" value="" v-model="smsCode" class="flex1"
						 placeholder="请输入验证码" />

					</view>
					<view class="submit-btn"  v-clickAgain="nextPage">
						确 定
					</view>
				</view>
			</view>

		</view>


	</view>
</template>

<script>
	import {
		addNotScroll,
		removeNotScroll,
		sendMsgHank
	} from '../../static/common.js'
	import {
		wftPay
	} from '../../api/wechatPay.js'
	import api from '../../api/index.js'
	export default {
		data() {
			return {
				isChecked: false,
				payInfo: "",
				isShowPayForm: false,
				phoneMsg: '获取验证码',
				phoneBtn: false,
				isBtn: false,
				b: -1,
				isActive: 0,
				questionList: [],
				homeList: [{
						relationName: '本人',
						isSelect: false,
						imgs: '../../static/image/home_self.png',
						relationType: 0,
						isClick: true
					},
					{
						relationName: '爱人',
						isSelect: false,
						imgs: '../../static/image/home_love.png',
						relationType: 1,
						isClick: true
					},
					{
						relationName: '父母',
						isSelect: false,
						imgs: '../../static/image/home_parent.png',
						isClick: true
					},
					{
						relationName: '子女',
						isSelect: false,
						imgs: '../../static/image/home-son.png',
						isClick: true
					}
				],
				prentList: [{
						name: '本人父亲',
						isSelect: false,
						relationType: 3
					},
					{
						name: '本人母亲',
						isSelect: false,
						relationType: 4
					},
					{
						name: '爱人父亲',
						isSelect: false,
						relationType: 5
					},
					{
						name: '爱人母亲',
						isSelect: false,
						relationType: 6
					}
				],
				sonList: [{
						'name': '子女1',
						isSelect: false,
						relationType: 2
					}, {
						'name': '子女2',
						relationType: 2,
						isSelect: false
					},
					{
						'name': '子女3',
						isSelect: false,
						relationType: 2
					}, {
						'name': '子女4',
						relationType: 2,
						isSelect: false
					}
				],
				mobileShow: false,
				type: 2,
				isShow: false,
				bottom: '-100%',
				mobile: '',
				smsCode: '',
				isFix: false,
				info: {},
				money: 0,
				planId: '',
				orderId: '',
				activateList: [],
			}
		},
		onLoad() {
			uni.pageScrollTo({
				scrollTop: 0,
				duration: 300
			});
			this.homeList.forEach(item => {
				item.isClick = true
			})
			this.sonList = [{
					'name': '子女1',
					isSelect: false,
					relationType: 2
				}, {
					'name': '子女2',
					relationType: 2,
					isSelect: false
				},
				{
					'name': '子女3',
					isSelect: false,
					relationType: 2
				}, {
					'name': '子女4',
					relationType: 2,
					isSelect: false
				}
			]
			this.prentList = [{
					name: '本人父亲',
					isSelect: false,
					relationType: 3
				},
				{
					name: '本人母亲',
					isSelect: false,
					relationType: 4
				},
				{
					name: '爱人父亲',
					isSelect: false,
					relationType: 5
				},
				{
					name: '爱人母亲',
					isSelect: false,
					relationType: 6
				}
			]
			// 获取常见问题列表
			this.getQuestionList()
		},
		onShow() {
			this.mobileShow = false
			// 获取可以加入互助计划的列表
			this.getCanJoinPlan()
		},
		methods: {
			// 解决ios键盘唤起，键盘收起以后页面不归位 
			changeBlur() {
				let u = navigator.userAgent,
					app = navigator.appVersion;
				let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
				if (isIOS) {
					setTimeout(() => {
						const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
						window.scrollTo(0, Math.max(scrollHeight - 1, 0))
					}, 200)
				}
			},
			//互助计划已加入的人员列表
			getlistByPlan(id) {
				api.myHelp.listByPlan({
					id: id
				}).then(res => {
					if (res.code == 1) {
						var list = res.data
						this.activateList = list
						this.notActivedDeal(list)
					}
				})

			},

			// 是否同意协议
			agree() {
				this.isChecked = !this.isChecked
			},
			// 获取未激活保障人信息
			notActivedDeal(list) {
				if (list.length == 0) {
					this.isBtn = false
					this.homeList.forEach(item => {
						item.isClick = true
					})
					return
				}

				var newList = []
				var childrenList = []
				for (var k in list) {
					newList.push(list[k].relationType)
					if (list[k].relationType == 2) {
						childrenList.push(list[k].relationType)
					}
				}

				if (newList.length == 8) {
					this.isBtn = true
				} else {
					this.isBtn = false
				}
				// 子女
				if (childrenList.length > 0 && childrenList.length < 4) {
					this.sonList.splice(0, childrenList.length)
				}
				if (childrenList.length == 4) {
					this.sonList.splice(0, 4)
					this.$set(this.homeList[3], "isClick", false)
				}

				// 本人
				if (newList.includes(0)) {
					this.$set(this.homeList[0], "isClick", false)
				}
				// 爱人
				if (newList.includes(1)) {
					this.$set(this.homeList[1], "isClick", false)
				}
				//本人父亲 3
				if (newList.includes(3)) {
					this.dealListIndex(this.prentList, 3)
				}
				//本人母亲
				if (newList.includes(4)) {
					this.dealListIndex(this.prentList, 4)
				}
				if (newList.includes(5)) {
					this.dealListIndex(this.prentList, 5)
				}
				if (newList.includes(6)) {
					this.dealListIndex(this.prentList, 6)
				}
				this.activateList = list
			},
			// 未激活(待实名认证)保障人数
			notActived(id) {
				api.joinHellp.notActived().then(res => {
					if (res.code == 1) {
						if (res.data != 0) {
							uni.navigateTo({
								url: '/pages/activateSafeguard/activateSafeguard?planId=' + id
							})
						}
					}
				})
			},
			// 删除已加入互助人员
			dealListIndex(obj, num) {
				obj.forEach((item, index) => {
					if (item.relationType == num) {
						obj.splice(index, 1)
					}

				})
				if (this.prentList.length == 0) {
					this.$set(this.homeList[2], "isClick", false)
				}
			},
			// 选择家人
			selectClick(index) {


				if (index == 0 && this.homeList[0].isClick == false) {
					return
				}
				if (index == 1 && this.homeList[1].isClick == false) {
					return
				}
				// 父母 
				if (index == 2 && this.prentList.length == 0) {
					return
				}
				if (index == 3 && this.homeList[3].isClick == false) {
					return
				}


				if (index == 0 || index == 1) {
					this.homeList[index]['isSelect'] = !this.homeList[index]['isSelect']
				}
				if (index == 2) {
					this.type = 1
					this.isShow = true
					this.bottom = '52rpx'
					addNotScroll()
				}
				if (index == 3) {
					this.type = 2
					this.isShow = true
					this.bottom = '52rpx'
					addNotScroll()
				}

			},
			// 获取问题列表
			getQuestionList() {
				var data = {
					categoryId: 122,
					pageNo: 1,
					pageSize: 10
				}
				api.joinHellp.getQuestionList(data).then(res => {
					if (res.code == 1) {
						var list = res.data.records
						for (var k in list) {
							list[k]['isSelect'] = false
						}
						this.questionList = list
					}
				})
			},

			// 获取可加入的互助计划
			getCanJoinPlan() {
				api.joinHellp.getCanJoinPlan().then(res => {
					if (res.code == 1) {
						this.info = res.data[0]
						this.money = res.data[0].price
						this.planId = res.data[0].id
							var that=this;
							setTimeout(function () {
								that.notActived(res.data[0].id)
								that.getlistByPlan(res.data[0].id)
							},600)
					}
				})
			},
			// 获取手机验证码
			getMobileCode() {
				sendMsgHank(this.mobile, this)
			},

			// 监听滚动事件
			onPageScroll(e) {
				if (e.scrollTop > 380) {
					this.isFix = true
				} else {
					this.isFix = false
				}
			},
			// 选择父母
			selectParent(index) {
				this.prentList[index]['isSelect'] = !this.prentList[index]['isSelect']

			},
			// 关闭弹框
			close(index) {
				this.isShow = false
				this.bottom = '-1000%'
				if (this.type == 1 && index == 2) {
					var list = this.prentList
					var isSelectPre = []
					for (var k in list) {
						if (list[k].isSelect) {
							isSelectPre.push(list[k])
						}
					}
					if (isSelectPre.length > 0) {
						this.homeList[2]['isSelect'] = true
					} else {
						this.homeList[2]['isSelect'] = false
					}

				}
				if (this.type == 2 && index == 2) {
					var listSon = this.sonList
					var isSelectSon = []
					for (var k in listSon) {
						if (listSon[k].isSelect) {
							isSelectSon.push(listSon[k])
						}
					}
					if (isSelectSon.length > 0) {
						this.homeList[3]['isSelect'] = true
					} else {
						this.homeList[3]['isSelect'] = false
					}

				}

				removeNotScroll()

			},
			// 选择子女
			selectSonClick(index) {
				this.b = index
				this.sonList[index]['isSelect'] = !this.sonList[index]['isSelect']


			}, // 去支付并跳到激活保障页面
			nextPage() {
				var mobileRegex = /^1\d{10}$/
				var codeRegex = /^\d{6}$/
				if (!mobileRegex.test(this.mobile)) {
					uni.showToast({
						title: '请输入正确的手机号',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				if (!codeRegex.test(this.smsCode)) {
					uni.showToast({
						title: '请输入正确的手机验6位数字证码',
						duration: 2000,
						icon: 'none'
					});
					return
				}
				var data = {
					mobile: this.mobile,
					validCode: this.smsCode,
					openId: uni.getStorageSync('openId')
					// openId: 'oFBKOwj0oFxwSbAlMgy0BCZKC1IQ'
				}
				api.wxAuth.mobileBind(data).then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: '绑定成功'
						})
						uni.setStorageSync('token', res.data.token);
						uni.setStorageSync('bindMobile', true);
						this.joinHelpAndPay()
					}
				})



			},
			// 显示和隐藏常见问题列表
			showOrHide(index) {
				this.questionList[index]['isSelect'] = !this.questionList[index]['isSelect']
			},
			// 加入互助并支付
			joinHelpAndPay() {
				// 加入互助
				var parm = []
				var selectList = this.homeList.slice(0, 2).concat(this.prentList).concat(this.sonList)
				for (var k in selectList) {
					if (selectList[k].isSelect) {
						parm.push({
							relationType: selectList[k]['relationType']
						})
					}
				}
				let personLength = parm.length
				removeNotScroll()
				api.joinHellp.joinHelpBtn(JSON.stringify(parm), {
					planId: this.planId
				}).then(ret => {
					if (ret.code == 1) {

						if (ret.msg === '请进入预约') {
							uni.navigateTo({
								url: `/pages/confirmOrder/appointmentOrder?planId=${this.planId}&personLength=${personLength}`
							});
						}
						this.orderId = ret.data.orderId;
						this.mobileShow = false;
						let advanceFlag = ret.data.advanceFlag; //判断订单是普通还是预售
						if (advanceFlag == 0) {
							uni.navigateTo({
								url: '/pages/confirmOrder/confirmOrder?orderId=' + this.orderId
							});
						} else if (advanceFlag == 1) {
							uni.navigateTo({
								url: '/pages/advanceSale/advanceSale?orderId=' + this.orderId
							});
						}
					}
				})

			},
			// 选择
			select(index) {
				this.type = index
				this.isShow = true
				this.bottom = '52rpx'
				addNotScroll()
			},


			// 关闭手机弹框
			closeMobileAlert() {
				removeNotScroll()
				this.mobileShow = false
			},
			// 绑定手机号
			bindMobile(type) {
				if (this.isBtn) {
					return
				}
				if (this.isChecked == false) {
					uni.showToast({
						title: '请选择阅读并勾选协议',
						icon: 'none'
					})
					if (type) {
						uni.pageScrollTo({
							scrollTop: 100,
							duration: 300
						});
					}
					return
				}
				var isBindMobile = uni.getStorageSync('bindMobile')
				var homeList = this.homeList
				var arry = []
				for (var k in homeList) {
					if (homeList[k]['isSelect']) {
						arry.push(homeList[k])
					}
				}
				if (arry.length > 0) {

					if (isBindMobile) {
						addNotScroll()
						this.joinHelpAndPay()
					} else {
						this.mobileShow = true
						addNotScroll()
					}

				} else {
					uni.showToast({
						title: '至少选择一人',
						icon: 'none'
					})
					if (type) {
						uni.pageScrollTo({
							scrollTop: 100,
							duration: 300
						});
					}
					return
				}


			}


		}
	}
</script>

<style>
	@import url("./joinPage.css");
</style>
